<?php
	session_start();
	$_SESSION["logged"] = true;
	
//	unset($_SESSION["logged"]);
?>

<html>
<head>
    	<title>ICS SAIS</title>
        
<link href="style/design.css" rel="stylesheet" type="text/css" />
 
<script type="text/javascript">
	 var RecaptchaOptions = { theme : 'white' };
	
	function form_type_display() {
		disable_all_forms();
		if (document.getElementById('type').value == 'student') {
			var className = 'student_form';
		} else if(document.getElementById('type').value == 'faculty'){
			var className = 'faculty_form';
		} else if(document.getElementById('type').value == 'encoder'){
			var className = 'encoder_form'
		}
		
		<!--get elements by class-->
		<!--http://stackoverflow.com/questions/3808808/how-to-get-element-by-class-in-javascript-->
		var elems = document.getElementsByTagName('*'), i;
		for (i in elems) {
			if((' ' + elems[i].className + ' ').indexOf(' ' + className + ' ')
					> -1) {
				elems[i].style.display = 'table-row';
				elems[i].required = "true";
			}
		}
	}
	
	function disable_all_forms(){
		var elems = document.getElementsByTagName('*'), i;
		var form_names = new Array();
		form_names[0] = 'student_form';
		form_names[1] = 'faculty_form';
		form_names[2] = 'encoder_form';
		for (h in form_names){
			for (i in elems) {
				if((' ' + elems[i].className + ' ').indexOf(' ' + form_names[h] + ' ')
						> -1) {
					elems[i].style.display = 'none';
					elems[i].required = "false";
				}
			}
		}
	}
	
	
</script>       

</head>
    
<body>
   	<div id="cont">
        	<div id="header">
            	<div id="header_main">
                	<div id="mhleft">
                    </div>
                    
                    <div id="mhcenter" ice:editable="*">
                    	<img src="style/ics_logo_blue.png" id="logo"/>
                      <div id="label_sais">
                        	<div id="border_label">	</div>
                        <div id="label"><p>Students'Academic
Information System</p></div>
                      </div>
                  </div>
                    
                    <div id="mhright">
                    </div>
                </div>
<?php
	if(!isset($_GET["page"]) || !isset($_SESSION["logged"])){
?>     
                <div id="bottomhead">
                	<div id="bhleft">
                    </div>
                    <div id="menu_bar">
                    	<!--login-->
                        <form method="post" action="processes/processLogin.php">
                          <table>
                                <tr>	<!--labels-->
                                	<td><label for="username">Username<label/></td>
                                    <td><label for="password">Password<label/></td>
                                    <td></td>
                                </tr>
                                <tr>	<!--forms-->
                                	<td><input type="text" name="username" id="username"/></td>
                                    <td><input type="password" name="password" id="password"/></td>
                                    <td><input type="submit" value="Login" name="login" class="sub_button" /></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
      <div id="body">
      	<div id="body_border">
        </div>
        <div id="announcement">
        </div>
        <div id="sign_up">
            <form name="sign_up" method="POST" onClick="form_type_display()"  action="verify.php">
           	<table>
                	<tr>
                    	<td colspan=1><h1>Sign Up</h1></td>
                        <td colspan=1><h1>&nbsp;&nbsp;&nbsp;&nbsp;</h1></td>
                        <td colspan=1><h1>&nbsp;&nbsp;&nbsp;&nbsp;</h1></td>
                    </tr>
                    <tr>
                    	<td colspan=1><label for="type" >User Type</label></td>
                        <td colspan=2><select name="type" id="type" class="sign_up_box" >
                                <option value="student">Student</option>
                                <option value="faculty">Faculty</option>
                                <option value="encoder">Encoder</option>
		                    </select>
                        </td>
                    </tr>
                    <!--Student Forms-->
                    <tr class="student_form" style="display:table-row">	<!--display: table-row-->
                    	<td colspan=1><label for="stud_num" title="xxxx-xxxxx format">Student Number</label></td>
                        <td colspan=2><input type="text" name="stud_num" id="stud_num" class="sign_up_box" pattern="[0-9]{4}-[0-9]{5}" required/></td>
                    </tr>
                    <!--insert other forms here class of tr should be "student_form"-->
                    <!--Student Forms-->
                    <!--Faculty Forms-->
                    <tr class="faculty_form" style="display:none">	<!--display: table-row-->
                    	<td colspan=1><label for="emp_num">Employee Number</label></td>
                        <td colspan=2><input type="text" name="emp_num" id="emp_num" class="sign_up_box"  pattern="[0-9]{9}" required/></td>
                    </tr>
                    <!--insert other forms here class of tr should be "faculty_form"-->
                    <!--Faculty Forms-->
                	<tr>
                    	<td colspan=1><label for="f_name">First Name</label></td>
                        <td colspan=2><input type="text" name="f_name" id="f_name" class="sign_up_box" pattern="[A-Za-z]+" required/></td>
                    </tr>
                    <tr>
                    	<td colspan=1><label for="l_name">Last Name</label></td>
                        <td colspan=2><input type="text" name="l_name" id="l_name" class="sign_up_box" pattern="[A-Za-z]+" required/></td>
                    </tr>
                    <tr>
                    	<td colspan=1><label for="m_name">Middle Name</label></td>
                        <td colspan=2><input type="text" name="m_name" id="m_name" class="sign_up_box" pattern="[A-Za-z]+" required/></td>
                    </tr>
                    <tr>
                    	<td colspan=1><label for="e_add">Email Address</label></td>
                        <td colspan=2><input type="email" name="e_add" id="e_add" class="sign_up_box" pattern="[A-Za-z0-9\._]+@[a-z]+\.[a-z]+" required/></td>
						
                    </tr>
                    <tr>
                    	<td colspan=1><label for="mob_num">Mobile Number</label></td>
                        <td colspan=2><input type="text" title="09xxxxxxxxx" name="mob_num" id="mob_num" class="sign_up_box" pattern="[0-9]{11}" required/></td>
                    </tr>
                    <tr>
                    	<td colspan=1><label for="pword_1">Password</label></td>
                        <td colspan=2><input type="password" name="pword_1" id="pword_1" class="sign_up_box" required/></td>
                    </tr>
                    <tr>
                    	<td colspan=1><label for="pword_2">Re-Enter Password</label></td>
                        <td colspan=2><input type="password" name="pword_2" id="pword_2" class="sign_up_box" required/></td>
                    </tr>
                     <!--reCaptcha-->
					<tr>
                        <td colspan=3>
                            <div id="captcha">
                                <?php
                                  require_once('recaptchalib.php');
                                  $publickey = "6Ld949sSAAAAACjy4uYHNRg4ty1oOZld3MHFF5qF"; // you got this from the signup page
                                  echo recaptcha_get_html($publickey);
                                ?>   
                            </div>
                        </td>
                    </tr>
                    <!--reCaptcha-->
                   	<tr>
                    	<td colspan=2>
                        	<a href="#"><label title="Request new password via e-mail.">Forgot your password?</label> </a>
                        </td>
                        <td colspan=1>
                        	<input type="submit" name="submit" value="Register" title="Submit account information." class="sub_button" id="register"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
<?php
	}
	//else if logged in
	//redirect to user page
?>
      </div>
   	</div>
    </body>
</html>